Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboarding: Replace react-confetti with @neoconfetti/react #30098

Merged
merged 9 commits into from
Dec 19, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Dec 18, 2024

Closes #30095

What I did

It looks like the dist code of react-confetti (maybe just the minified version) contains code, that makes it impossible for esbuild to understand the requires/imports. It might just be too dynamic due to some syntax-compression/optimization.

Instead of diving deep into the rabbit hole, we propose replacing the dependency (which is unmaintained) with a newer, well maintained replacement, @neoconfetti/react.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

I tested this manually by making a prod build of the addon package, and copying this over to a project I had, that I verfied was showing the problem before.

QA should include going through the onboarding process once, and verifying there is confetti.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 972 B 1.94 0%
initSize 136 MB 136 MB -19.3 kB -4.01 0%
diffSize 58.4 MB 58.4 MB -20.3 kB -5.26 0%
buildSize 7.24 MB 7.22 MB -19.2 kB -17.01 -0.3%
buildSbAddonsSize 1.88 MB 1.86 MB -15.1 kB -Infinity -0.8%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.86 MB -4.06 kB -0.16 -0.2%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.94 MB 3.92 MB -19.2 kB -16.94 -0.5%
buildPreviewSize 3.3 MB 3.3 MB 0 B -0.66 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.7s 24.5s 17.7s 1.24 🔺72.4%
generateTime 18.8s 22.7s 3.8s 1.34 🔺17%
initTime 13.4s 16.9s 3.4s 2.47 🔺20.5%
buildTime 9.9s 8.7s -1s -192ms -1.01 -13.6%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 7.2s 5.5s -1s -677ms 0.18 -30.2%
devManagerResponsive 5.3s 4.1s -1s -152ms 0.28 -27.6%
devManagerHeaderVisible 998ms 655ms -343ms -0.18 -52.4%
devManagerIndexVisible 1s 681ms -360ms -0.28 -52.9%
devStoryVisibleUncached 2.8s 2s -852ms 0.37 -42.5%
devStoryVisible 1s 680ms -358ms -0.28 -52.6%
devAutodocsVisible 975ms 585ms -390ms -0.06 -66.7%
devMDXVisible 981ms 586ms -395ms -0.03 -67.4%
buildManagerHeaderVisible 1.1s 687ms -470ms 0.02 -68.4%
buildManagerIndexVisible 1.2s 781ms -499ms -0.02 -63.9%
buildStoryVisible 1s 640ms -406ms 0.04 -63.4%
buildAutodocsVisible 941ms 616ms -325ms 0.87 -52.8%
buildMDXVisible 770ms 563ms -207ms 0.59 -36.8%

Greptile Summary

Replaces react-confetti with react-confetti-boom to resolve esbuild bundling issues in the onboarding addon, resulting in significant bundle size improvements.

  • Modified code/addons/onboarding/src/components/Confetti/Confetti.tsx to use react-confetti-boom with simplified implementation
  • Added new e2e test code/e2e-tests/addon-onboarding.spec.ts to verify onboarding flow functionality
  • Reduced buildSbAddonsSize by 24.5% (from 1.88MB to 1.51MB)
  • Simplified confetti configuration in code/addons/onboarding/src/Onboarding.tsx by using default values

Copy link

nx-cloud bot commented Dec 18, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f202d2a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Dec 18, 2024

Package Benchmarks

Commit: f202d2a, ran on 18 December 2024 at 15:19:25 UTC

The following packages have significant changes to their size or dependencies:

@storybook/addon-onboarding

Before After Difference
Dependency count 0 0 0
Self size 235 KB 218 KB 🎉 -16 KB 🎉
Dependency size 664 B 664 B 0 B
Bundle Size Analyzer Link Link

@yannbf yannbf marked this pull request as ready for review December 18, 2024 10:24
@yannbf yannbf changed the title Onboarding: Use source of react-confetti Onboarding: Replace react-confetti with react-confetti-boom Dec 18, 2024
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

return container;
});
}: ComponentProps<typeof ReactConfetti> & { timeToFade?: number }) {
const [particleCount, setParticleCount] = useState(42);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: initial particleCount of 42 seems arbitrary and much lower than original implementation which could affect visual impact

@yannbf yannbf changed the title Onboarding: Replace react-confetti with react-confetti-boom Onboarding: Replace react-confetti with @neoconfetti/react Dec 19, 2024
@yannbf yannbf merged commit 6f04c27 into next Dec 19, 2024
59 of 60 checks passed
@yannbf yannbf deleted the norbert/fix-confetti-bundling branch December 19, 2024 07:40
@github-actions github-actions bot mentioned this pull request Dec 19, 2024
6 tasks
@ndelangen ndelangen added the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Dec 20, 2024
@yannbf yannbf removed the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Error: Dynamic require of "react" is not supported
2 participants